import request from '@/utils/request'
// 获取数据
export default function fetchData(url, params, method = 'get') {
  return new Promise((resolve, reject) => {
    const config = {
      method: method,
      url: url
    };
    (method === 'get') ? (config.params = params) : (config.data = params)
    request(config)
      .then(
        res => {
          resolve(res)
        },
        err => {
          console.log(err)
          reject(err)
        }
      )
      .catch(error => {
        console.log(error)
        reject(error)
      })
  })
}

export function login(data) {
  return fetchData({
    url: '/api1/UserLogin',
    data,
    method: 'post'
  })
}
